﻿using AutoMapper;
using MediatR;
using S.Breeding.Api.Application.Command.OustManageCommand;
using S.Breeding.Domain;
using S.Breeding.Infrastructure;

namespace S.Breeding.Api.Application.CommandHandlers.OustManageCommandHandlers
{
    public class OustManageDeleteCommandHandlers : IRequestHandler<OustManageDeleteCommand, int>
    {
        private readonly IRepository<OustManage> repository;
        private readonly IMapper mapper;
        public OustManageDeleteCommandHandlers(IRepository<OustManage> repository, IMapper mapper)
        {
            this.repository = repository;
            this.mapper = mapper;
        }

        public async Task<int> Handle(OustManageDeleteCommand request, CancellationToken cancellationToken)
        {
            return await repository.DeleteAllAsync(x => x.OMId == request.OMId);
        }
    }
}
